/*
 * 路由分发
 */
var router_config = {
	"/api/complex/login": require("./router/complex/User_Login"),
	"/api/complex/MyCalendar": require("./router/complex/MyCalendar"),
	"/api/complex/MyNote": require("./router/complex/MyNote"),
	"/api/complex/Upload": require("./router/complex/Upload"),
	"/api/complex/MyInfo": require("./router/complex/MyInfo"),
	"/api/complex/ChatApi": require("./router/complex/ChatApi"),
	"/api/complex/FriendsApi": require("./router/complex/FriendsApi"),
	"/api/complex/MyCourse": require("./router/complex/MyCourse"),
	"/api/complex/MyCourseDetail": require("./router/complex/MyCourseDetail"),
	"/api/complex/MyVideo": require("./router/complex/MyVideo"),
	"/api/complex/StudentCourse": require("./router/complex/StudentCourse"),
	"/*": require("./router/static_file"),
}

var _router_error = function(req, res) {
		res.send(404, "404 no find.");
		console.error("----404----");
		console.log(req.route);
		console.error("----404----");
	}
	// 打印数据库接口
var router = function(app) {
	for (var i in router_config) {
		(function(router_key) {
			var router_object = router_config[router_key];
			console.log("路由器初始化配置接口：", router_key);
			app.all(router_key, function(req) {
				var router_foo = router_object[req.method.toLowerCase()] || _router_error;
				router_foo.apply(app, arguments);
			})
		}(i));
	}
}
module.exports = router;